How To Create Lightmaps of a Scene?

I’m developing a new file format for describing a world. Now I got some trouble with lighting.
That is how i generate a lightmap due to the lights i put in this world? What i should do to calculate color of the lightmap?
a raytrace is needed?

raycasting will do it. (you don’t need to trace the reflections…)
offscreen-rendering will do it too.(render the texture form the lightsource as pov)
google for tutorials.