Treatment of wastewater by ultrafiltration