Handle BrokenPipe, StandardError and IOError in fat_wrote and break out

This fixes issue #368