Image Encoder returns corrupted data