def human_bytes(size):
    """
    Convert a given size (in bytes) to a human-readable representation.

    :param int size: Size in bytes.
    :return: Human-readable representation of size, e.g. 1MB.
    :rtype: str
    """

    for x in ("B", "KB", "MB", "GB"):
        if size < 1024.0 and size > -1024.0:
            return "%3.1f%s" % (size, x)
        size /= 1024.0
    return "%3.1f%s" % (size, "TB")