JPEGImageReader throws "IllegalStateException: sourceRegion.height <= subsamplingYOffset!"

If the height of the last part of the image to read is less than the y source subsampling offest, then the image reader will fail with the exception:
java.lang.IllegalStateException: sourceRegion.height <= subsamplingYOffset!
at javax.imageio.IIOParam.setSourceRegion(IIOParam.java:206)
at com.twelvemonkeys.imageio.plugins.jpeg.JPEGImageReader.readImageAsRasterAndReplaceColorProfile(JPEGImageReader.java:423)
at com.twelvemonkeys.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:304)
at com.twelvemonkeys.servlet.image.ImageServletResponseImpl.getImage(ImageServletResponseImpl.java:387)

I added some test cases (not all of them are failing, I added a few extra just to be sure) and a proposed fix. The proposed fix is to set the subsamplingYOffest to 0 in the failing scenario.