def chunks(seq, size):
    """Breaks a sequence of bytes into chunks of provided size

    :param seq: sequence of bytes
    :param size: chunk size
    :return: generator that yields tuples of sequence chunk and boolean that indicates if chunk is
             the last one
    """
    length = len(seq)
    return ((seq[pos:pos + size], (pos + size < length))
            for pos in range(0, length, size))