fix up the image resizing code