pbm: Move "bit to buffer" routine to its own static function