Improved image conversion algorithm.