In that case: raise more preflop (I make it 0.60$ OOP), bet WAY more on the flop, 2/3 pot instead of less than half.
He's repping the flush on the turn, but you'd have to make a really big fold to let it go here with still 10 outs to improve if behind with a set.
Since he DIDN'T have a flush, you put your chips in the center as a favourite and HE sucked out.
He had 9 outs, though, so it's hardly a bad beat, and you were ahead so it was a good call.
Smile at making the correct decision, and play the next hand.