Methane production and recovery from wastewater