Index: Source/Python/Classes/EcFlexpart.py
===================================================================
--- Source/Python/Classes/EcFlexpart.py	(revision 8c1d1757c670781238d3cc6829dd992d7848863e)
+++ Source/Python/Classes/EcFlexpart.py	(revision c77630a97116cfe48788a474eaf76b1887d1479f)
@@ -1094,7 +1094,7 @@
 
             print("outputfile = " + fnout)
-            f_handle = open(fnout, 'w')
-            h_handle = open(hnout, 'w')
-            g_handle = open(gnout, 'w')
+            f_handle = open(fnout, 'wb')
+            h_handle = open(hnout, 'wb')
+            g_handle = open(gnout, 'wb')
 
             # read message for message and store relevant data fields, where
@@ -1402,5 +1402,5 @@
             # write original time step to flux file as usual
             fluxfile = GribUtil(os.path.join(c.inputdir, fluxfilename))
-            fluxfile.set_keys(tmpfile, filemode='a', strict=True,
+            fluxfile.set_keys(tmpfile, filemode='ab', strict=True,
                               wherekeynames=['paramId'], wherekeyvalues=[142],
                               keynames=['perturbationNumber','date','time','stepRange','values'],
@@ -1408,5 +1408,5 @@
                                          date.hour*100, 0, lsp_new_np[inumb,:,it]],
                              )
-            fluxfile.set_keys(tmpfile, filemode='a', strict=True,
+            fluxfile.set_keys(tmpfile, filemode='ab', strict=True,
                               wherekeynames=['paramId'], wherekeyvalues=[143],
                               keynames=['perturbationNumber','date','time','stepRange','values'],
@@ -1416,5 +1416,5 @@
 
             # rr for first subgrid point is identified by step = 1
-            fluxfile.set_keys(tmpfile, filemode='a', strict=True,
+            fluxfile.set_keys(tmpfile, filemode='ab', strict=True,
                               wherekeynames=['paramId'], wherekeyvalues=[142],
                               keynames=['perturbationNumber','date','time','stepRange','values'],
@@ -1422,5 +1422,5 @@
                                          date.hour*100, '1', lsp_new_np[inumb,:,it+1]]
                               )
-            fluxfile.set_keys(tmpfile, filemode='a', strict=True,
+            fluxfile.set_keys(tmpfile, filemode='ab', strict=True,
                               wherekeynames=['paramId'], wherekeyvalues=[143],
                               keynames=['perturbationNumber','date','time','stepRange','values'],
@@ -1430,5 +1430,5 @@
 
             # rr for second subgrid point is identified by step = 2
-            fluxfile.set_keys(tmpfile, filemode='a', strict=True,
+            fluxfile.set_keys(tmpfile, filemode='ab', strict=True,
                               wherekeynames=['paramId'], wherekeyvalues=[142],
                               keynames=['perturbationNumber','date','time','stepRange','values'],
@@ -1436,5 +1436,5 @@
                                          date.hour*100, '2', lsp_new_np[inumb,:,it+2]]
                               )
-            fluxfile.set_keys(tmpfile, filemode='a', strict=True,
+            fluxfile.set_keys(tmpfile, filemode='ab', strict=True,
                               wherekeynames=['paramId'], wherekeyvalues=[143],
                               keynames=['perturbationNumber','date','time','stepRange','values'],
@@ -1466,8 +1466,8 @@
 
         gribfile.copy_dummy_msg(ifile, keynames=['paramId'],
-                      keyvalues=[142], filemode='w')
+                      keyvalues=[142], filemode='wb')
 
         gribfile.copy_dummy_msg(ifile, keynames=['paramId'],
-                      keyvalues=[143], filemode='a')
+                      keyvalues=[143], filemode='ab')
 
         return
@@ -1573,5 +1573,5 @@
                 fortfile = os.path.join(c.inputdir, 'fort.' + k)
                 silent_remove(fortfile)
-                fdict[k] = open(fortfile, 'w')
+                fdict[k] = open(fortfile, 'wb')
 #============================================================================================
             # create correct timestamp from the three time informations
@@ -1608,5 +1608,5 @@
             #    if 'olddate' not in locals() or cdate != olddate:
             #        fwrf = open(os.path.join(c.outputdir,
-            #                    'WRF' + cdate + '.' + ctime + '.000.grb2'), 'w')
+            #                    'WRF' + cdate + '.' + ctime + '.000.grb2'), 'wb')
             #        olddate = cdate[:]
 #============================================================================================
