@Mark, but in this case the data being written out is an image and encoding it to a str does not make much sense.