Limit the total number of lines processed in bundle mode to image height

When processing the last bundle of an image, make sure that we don't
try to process extra data past the end of the source image.  This also
guarantees that we don't output past the end of the destination image.