improved image handling