func (b *BitWriter) WriteByte(byt byte) error {
	b.b[0] |= byt >> (8 - b.count)
	if n, err := b.w.Write(b.b[:]); n != 1 || err != nil {
		return err
	}
	b.b[0] = byt << b.count
	return nil
}
WriteByte writes a single byte to the stream, regardless of alignment
package bitstream
import (
	"io"
)
type Bit bool
const (
	Zero Bit = false
	One Bit = true
)
type BitReader struct {
	r     io.Reader
	b     [1]byte
	count uint8
}
type BitWriter struct {
	w     io.Writer
	b     [1]byte
	count uint8
}
func NewReader(r io.Reader) *BitReader {
	b := new(BitReader)
	b.r = r
	return b
}
func (b *BitReader) ReadBit() (Bit, error) {
	if b.count == 0 {
		if n, err := b.r.Read(b.b[:]); n != 1 || (err != nil && err != io.EOF) {
			return Zero, err
		}
		b.count = 8
	}
	b.count--
	d := (b.b[0] & 0x80)
	b.b[0] <<= 1
	return d != 0, nil
}
func NewWriter(w io.Writer) *BitWriter {
	b := new(BitWriter)
	b.w = w
	b.count = 8
	return b
}
func (b *BitWriter) Pending() (byt byte, vals uint8) {
	return b.b[0], b.count
}
func (b *BitWriter) Resume(data byte, count uint8) {
	b.b[0] = data
	b.count = count
}
func (b *BitWriter) WriteBit(bit Bit) error {
	if bit {
		b.b[0] |= 1 << (b.count - 1)
	}
	b.count--
	if b.count == 0 {
		if n, err := b.w.Write(b.b[:]); n != 1 || err != nil {
			return err
		}
		b.b[0] = 0
		b.count = 8
	}
	return nil
}