US retail giant Safeway has struck a deal with unions in Northern California representing around 25,000 workers.