Improve the binary encoding spec and add a file encoder.