use bit_length rather than log2_int function in mask.py