Ronnie O'Sullivan pieced together a closing 80 to overcome Mark Allen 4-2 in a high-quality encounter at the European Masters in Bucharest.