This type check fixes a problem with <IE10 browsers

I noticed this was causing errors with browsers that doesn't have `Uint32Arrays`.

Problem simply was that JS throws an error if you're trying to access a global variable that isn't defined. I just added proper type checks for those places.

The check for `window` doesn't really matter for browsers, but if someone's running this outside of browser environment (Rhino/Node/etc), they would have encountered the same problem, so I fixed those too.