function randomBytes (size) {
  var bytes = new Array(size);
  var r;

  for (var i = 0, r; i < size; i++) {
    if ((i & 0x03) == 0) r = Math.random() * 0x100000000;
    bytes[i] = r >>> ((i & 0x03) << 3) & 0xff;
  }

  return bytes;
}
Taken from the crypto-browserify module
https://github.com/dominictarr/crypto-browserify
NOTE: Math.random() does not guarantee "cryptographic quality" but we actually don't need it