Piston valves for CO2 purification and liquefication