I do tonemapping in a final compositing step of deferred rendering. Here are formulas:
http://filmicgames.com/archives/75
John Hable did a great job proselytizing virtues of linear space lighting and proper tonemapping.
http://filmicgames.com/archives/category/tonemapping
http://filmicgames.com/archives/category/gamma
There have been also SIGGRAPH course if you want to delve-in deeper: