Simple binary encoding and decoding.