FIx encoding problem with image data