Replace failure with an error.
Added convenience function to save a buffer

Make it more convenient to write a buffer to a file.
Open the file write-only.
fixed formatting