Greggs to cut 740 jobs and close factories