Thermal energy storage for medium and high temperatures