Spectral reconstruction of kilovoltage photon beams using generalized simulated annealing