def bytes_split(bytes_, length):
    """Split bytes into pieces of equal size."""
    n_pieces, excess = divmod(len(bytes_), length)
    if excess:
        raise ValueError('Bytes of length {} cannot be equally divided into '
                         'pieces of length {}'.format(len(bytes_), length))
    return [bytes_[i * length : (i + 1) * length] for i in range(n_pieces)]