Change Writer API to Encoder

This is too goofy to shoehorn into io.Writer
Add a test and fix some encoding bugs
Move encoder to own file
Move package comment to header.go
Rename write_test to encode_test
Reuse a buffer

Rather than allocating one for every page
Add decoding

And export COP, BOS, and EOS.