MAINT: refactor packbits/unpackbits

Pushes the GIL release one loop outward.
`nin` and `nout` might look better and correspond to other usage.