Allow for specifying imports at beginning of templates

This fixes https://github.com/playframework/playframework/issues/1648.  It worked in my own local testing. However, ./runtests failed with this change. Perhaps someone more knowledgeable of this code has some ideas on tweaking it