diff --git a/geomagio/residual/CalFileFactory.py b/geomagio/residual/CalFileFactory.py
index 173bde7e8ab7fe0f5079b0cedc935d1bbdb489d2..b0602d4a70491dfc029316036bbca439d8487a3a 100644
--- a/geomagio/residual/CalFileFactory.py
+++ b/geomagio/residual/CalFileFactory.py
@@ -52,7 +52,7 @@ class CalFileFactory(object):
         # generate string holding cal file's contents
         cal_str = self.format_readings(readings)
         with open(path, "wb") as f:
-            f.write(cal_str)
+            f.write(cal_str.encode())
 
 
 """