def decode(commands):
    """
    decodes given commands to plain buffer of unpacked bytes

    Parameters
    ----------
    commands : dictionary list
        commands to unpack

    Returns
    -------
    buffer : list of ints
        unpacked bytes list.

    """
    buffer = []
    for com in commands:
        if com["method"] == "rle":
            buffer += com["chunk"] * com["len"]
        elif com["method"] == "lz":
            lz_offs = com["offs"]
            lz_len = com["len"]
            # for lz outbound copy
            cyclic_buffer = buffer + buffer[lz_offs:] * lz_len
            buffer += cyclic_buffer[lz_offs: lz_offs+lz_len]
        else:  # raw copy
            buffer += com["data"]
    return buffer