A new deal will keep a Maine waste-to-energy facility going even after its contract with local municipalities ends in 2018.