Tentative agreement reached to avert possible rail strike