Allow direct read/write to/from io streams

We're working with some rather large bitsets (bloom filters, actually,
and I'll be making a similar change to your very fine bloom filter
library as well). They're large enough that we may not be easily able
to hold an extra copy or two in memory for the conversion-to-JSON
process.

Instead, we just want to be able to serialize a bitset straight to a
file stream. The preexisting code already does that; it just uses a
bytes.Buffer instead. So I've just moved the parts that do the binary
encoding/decoding into separate exported functions and used the new
encoding functions in the guts of MarshalJSON and UnmarshalJSON.

The tests still exercise the new functionality, so I didn't make any
additions there.

Hopefully someone else may find this useful.