Search for diphoton resonances in the mass range from 150 to 850 GeV in pp collisions at sqrt(s) = 8 TeV