def block_format(pieces, width=79):
    """Concatenate strings, adding newlines.

    pieces -- iterable of bytes-like objects
    width  -- int (default 79)

    Returns b"".join(pieces), with added newlines between pieces as necessary
    to avoid lines longer than 'width' (using nothing more sophisticated than a
    byte-count).

    Leaves newlines inside 'pieces' untouched, and ignores them in its width
    calculation. If a single piece is longer than 'width', it will become a
    single long line in the output.

    """
    lines = []
    line = b''
    for bb in pieces:
        if len(line) + len(bb) > width:
            lines.append(line)
            line = b''
        line += bb
    if line:
        lines.append(line)
    return b'\n'.join(lines)
