Fixed endless loop when processing broken images.