Make `GenJSFiles` flexible enough to handle VirtualFiles

This means not-NPEing due to their lack of physical existence, and properly writing to `baseDir` when it is a VirtualDirectory rather than dumping all its output inconveniently on the filesystem.

I have not run partest since it is broken due to https://github.com/scala-js/scala-js/issues/281, but I have run all of these guys (http://lihaoyi.github.io/workbench-example-app/triangle.html) (http://lihaoyi.github.io/workbench-example-app/dodge.html) and it seems to work. You'll need to verify.