improved image extraction