Thermal treatment of materials