Modified encoding to return an array containing the image pixels
(instead of saving it in a file).