Fix usage of res.locals in Express 3.x

This patch is needed to work with Express 3.x, tested on 3.0.5 and 3.1.0

I'm using ejs 0.8.3 as a template engine.

Resubmitting this as a separate PR