Improved image handling