Buffer overflows have been fixed by making the buffers at least 3 bytes larger than the image itself needs.
This is required for some tiffcrop conversion subroutines.
In addition, some integer casting warnings have been fixed.
Closes issues #271, #381, #386, #388, #389 and #435.