MAINT: refactor packbits/unpackbits

Pushes the GIL release one loop outward.
Not convinced it is worth making this a separate function.