def bitmap_to_bytes(bitmap):
    """Turn bitmap into string of bytes

    The returned value is representation of bitmap suitable for store
    in the DataFrame, and ultimately in the HDF5 file.

    Parameters
    ----------
    bitmap : BitMap
        Bitmap / bitset, which representation we want to get.

    Returns
    -------
    bytes (str in Python 2.x)
        [Compact] representation of bitmap as bytes.  Note that it may
        contain NUL ('\x00') characters.

    """
    return bitmap.bitmap.tostring()