use Universal Module Definition to support AMD and CommonJS

Changed the module wrapper to use UMD. This supports AMD, CommonJS and exporting to root (ie vanilla script tag).