Add better range validation to BitstreamWriter methods.

This tries to ensure that one doesn't push values into a write
that are outside its range of bits.
Fix glitch in Python-implemented FLAC encoder.