Export to GeoTIFF refactor.

This PR refactors the GeoTIFF export mechanism and addresses several bugs/caveats.