Niall McGinn scored twice from the spot as Aberdeen came from behind to beat Motherwell 3-1 at Fir Park.