A pure substance can be a gas, a liquid or a solid. To get a solid to change to a liquid and then a gas it has to be heated.  To make a gas turn into a liquid and then a solid, heat has to be taken away.
	
The most common example is when ice turns to water and then evaporates into a gas.  In the immense cold of  outer space hydrogen, a gas on Earth, looks like solid rock.