TIF output support of Exif (only available for libtiff >= 4.0.2)

Earlier versions of libtiff (including the version that was current when
we added Exif reading to our tiff support) supported reading Exif, but
not writing Exif. Later versions of libtiff have added this capability.
Make TIFF error message storage thread-safe