Separation of carbon dioxide for biogas upgrading to biomethane