@@ -469,7 +469,7 @@ def draw_image(self, gc, x, y, im, dx=None, dy=None, transform=None):
469469 im .flipud_out ()
470470
471471 h , w , bits , imagecmd = self ._get_image_h_w_bits_command (im )
472- hexlines = '\n ' .join (self ._hex_lines (bits ))
472+ hexlines = b '\n ' .join (self ._hex_lines (bits )). decode ( 'ascii' )
473473
474474 if dx is None :
475475 xscale = w / self .image_magnification
@@ -1179,6 +1179,7 @@ def write(self, *kl, **kwargs):
11791179 print ("end" , file = fh )
11801180 print ("showpage" , file = fh )
11811181 if not isEPSF : print ("%%EOF" , file = fh )
1182+ fh .flush ()
11821183
11831184 if rcParams ['ps.usedistiller' ] == 'ghostscript' :
11841185 gs_distill (tmpfile , isEPSF , ptype = papertype , bbox = bbox )
@@ -1187,7 +1188,7 @@ def write(self, *kl, **kwargs):
11871188
11881189 if passed_in_file_object :
11891190 with open (tmpfile , 'rb' ) as fh :
1190- print (fh .read (), file = outfile )
1191+ outfile . write (fh .read ())
11911192 else :
11921193 with open (outfile , 'w' ) as fh :
11931194 pass
@@ -1293,6 +1294,7 @@ def write(self, *kl, **kwargs):
12931294 #print >>fh, "grestore"
12941295 print ("end" , file = fh )
12951296 print ("showpage" , file = fh )
1297+ fh .flush ()
12961298
12971299 if isLandscape : # now we are ready to rotate
12981300 isLandscape = True
0 commit comments