def _format_size(size):
    """
    Format a size in bytes as a sting Tib, Gib, Mib.

    Parameters
    ----------
    size: int
        The size in bytes.

    Returns
    -------
        str: the size string.
    """
    size_mb = float(size)/1048576
    size_str = '%10.2f MiB' % size_mb
    if size_mb > 1024:
        size_gb = size_mb/1024
        size_str = '%10.2f GiB' % size_gb
    else:
        return size_str
    if size_gb > 1024:
        size_tb = size_gb/1024
        size_str = '%10.2f TiB' % size_tb
    return size_str.strip()