Fixed issue with saving images as jpegs