first you need a camera that has shutterspeed ability.
You need to use manual exposure for this
I use a pentax D110, but Canon Rebel, and Nikon D series work as well.
set the shutter speed(has to be slow to capture the light) I use a low shutter speed like a 2 or 6 and apture of F16.
place the camera on the tripod
keep it steady
now get someone to wave the flashlight around, to create the lightwriting effect,
now push the shutter button and wait for the click(this tells you the picture has been taken)
and then you can get this