Teachers agree to three-year contract, pay increases