There was late drama at Livingston where Falkirk scored a stoppage time winner to reach the Scottish Cup fifth round.