Adds header and crc processing to write. Resolves issue #1.