MAINT: refactor packbits/unpackbits

Pushes the GIL release one loop outward.
The diff is confusing; this is actually the old line 1432 in the `if (unpack)` block above.