Improved handling of images and image attachments