Wales edged past France 20-19 to reach the Rugby World Cup semi-finals, helped by a red card for Sebastian Vahaamahina early in the second-half.