Architecture-dependent to DataView
Using DataView is pretty much the same thing. Probably slower though. But it allows you to see that you only have to worry about endianness when dealing with values using more than one byte, like you do when storing width and height using 4 unsigned bytes each.

// Getting pixels as a byte (uint8) array
var imageData = ctx.getImageData(0, 0, can.width, can.height);
var pixels8BitsRGBA = imageData.data;

var i;
var pixelsAs32Bits = new Uint32Array(pixels8BitsRGBA.length + 8); // +8 bytes for the two leading UInt32
var pixelsARGB = new DataView(pixelsAs32Bits.buffer);

// Reverting bytes from RGBA to ARGB
pixelsARGB.setUint32(0, can.width, true); // little endian
pixelsARGB.setUint32(4, can.height, true);  // little endian
for(i = 0; i &lt; pixels8BitsRGBA.length ; i += 4) {
    pixelsARGB.setUint8(i + 8, pixels8BitsRGBA[i + 3]);
    pixelsARGB.setUint8(i + 9, pixels8BitsRGBA[i]);
    pixelsARGB.setUint8(i + 10, pixels8BitsRGBA[i + 1]);
    pixelsARGB.setUint8(i + 11, pixels8BitsRGBA[i + 2]);
}

console.log(pixelsAs32Bits);