def writeInt(value, nbytes=4):
    """Write nbytes length integer encoded little endian.

    """
    outbytes = bytearray(nbytes)
    for idx in range(nbytes):
        outbytes[idx] = value & 0xff
        value = value >> 8
    return bytes(outbytes)