fix bug in gate_expand_3toN

for the case when N=3 and targets and controls are only permuted