Separating impurities from carbon dioxide