Fix encoding of images