The company behind a major pipeline project in Sonora — the Mexican state to Arizona’s south — has reached a deal to avoid losing the contract.