Throw exceptions on write failures.
Merge pull request #46 from mdx-dev/write_exceptions

Throw exceptions on write failures.