If you're in chiang mai, just go to the immigration office (which is on the left between airport plaza shopping mall and the airport itself). Take the items and money mentioned above by Gregor and you'll soon have your 30 day extension to your Visa-exempt entry.
Unless you are connecting directly from the domestic to international flight, you'll not see immigration in CNX. if the connection is direct you'll get your mini wrist-slapping at CNX.