Proper buffer management. Don't write beyond the end of the bitbuffer.
Merge pull request #2 from cladisch/bitbuffer-overflow

fix a buffer overflow