Removal of water or carbon dioxide from the reaction mixture or reaction components