Phase-transfer catalyzed synthesis of amides and esters of carboxylic acids