Teachers union and school board agree to contract