def tob32(val):
    """Return provided 32 bit value as a string of four bytes."""
    ret = bytearray(4)
    ret[0] = (val>>24)&M8
    ret[1] = (val>>16)&M8
    ret[2] = (val>>8)&M8
    ret[3] = val&M8
    return ret
Return provided 32 bit value as a string of four bytes.