Volkswagen has reached an agreement with workers at its Mexican plant to avoid a strike threatened by the factory's union.