Ensure bits are correctly terminated

If the encoded data was within 4 bits of the maximum size for the given
version, it was not being correctly terminated.

Fixes #26