Several fixes for the handling of formats with negative origins.

This pull request fixes several bugs that appear when using images whose formats have negative origins. The results have been meticulously compared to those of other software and empirically validated. Some test cases that were in fact wrong, have been corrected to reflect the changes. 

This also fixes a bug in the reformat node which was producing the wrong results when an image with an offset display window is reformatted to another offset format.