High street bakery brand Greggs has announced plans to shut four of its factories and cut 740 jobs.