make sure cached file is deleted if exception thrown during write
Merge pull request #2 from tkunicki-usgs/master

Looks good, we should probably release this and then NWC in turn.