Greggs to close four factories and cut 740 jobs