MAINT: refactor packbits/unpackbits

Pushes the GIL release one loop outward.
See the unit test. Feel free to suggest further tests, since it is rather minimal.