fixed bugs in image import code.