bits2bytes: fix handling of invalid bits