def _format_size( fsize_b ):
    """
    Formats the bytes value into a string with KiB, MiB or GiB units. This code has been copied from :py:meth:`deluge's format_size <deluge.ui.console.utils.format_utils.format_size>`.
    
    :param int fsize_b: the filesize in bytes.
    :returns: formatted string in KiB, MiB or GiB units.
    :rtype: str
    **Usage**
    
    >>> format_size( 112245 )
    '109.6 KiB'
    """
    fsize_kb = fsize_b / 1024.0
    if fsize_kb < 1024:
        return "%.2f KiB" % fsize_kb
    fsize_mb = fsize_kb / 1024.0
    if fsize_mb < 1024:
        return "%.2f MiB" % fsize_mb
    fsize_gb = fsize_mb / 1024.0
    return "%.2f GiB" % fsize_gb