Fix a bug that might cause an extra character to be decoded.

The fix stores the original input length in the encoded file, so that
trailing zero bits in the encoding are not interpreted as significant.