TSMC flags better times ahead as Q3 profit beats expectations