source code modified for libtiff issue in macosx (and other systems)