More error checking in image resizing code