Added functionality to possibly convert the encoding of the images