Thermodynamic aspects of freeze-drying