Three-chamber bioelectrochemical system for biogas upgrading and nutrient recovery