Improve handling of collection names in generated JS

1. Generate correct mongo shell syntax for collections with names that aren't valid dot-separated JS identifiers.
2. Change generated names for temporary collections so that they are valid dot-separated JS identifiers, and to put them all under a `tmp` pseudo-namespace (so that they appear in the API as sharing a `tmp/` sub-directory.

This is another extract from my WIP branch for #140.
OK, then go ahead and add it as a second parameter. Anything to avoid hard coding a bogus value in there.