I haven't touched this code in a while, but my sense is that this line is incorrect.  Shouldn't we be referencing roughThumbnail.getWidth() and roughThumbnail.getHeight() rather than imageWidth and imageHeight?