Mark blocks as free if cannot write file

* Blocks were not being marked free if the file could not be written;
  this stopped smaller files be written when a much larger one had
  failed.
* Fix encryption/decryption