Added code for bits_to_mask function.  Validated on a few lines,
needs more testing.