MAINT: refactor packbits/unpackbits

Pushes the GIL release one loop outward.
Here is the zero dims check.