NSW teachers to be given greater job security after agreement between department and federation