Allow array buffer usage when possible

- using `Int32Array()` if supported (fallback to common `Array`);
- caching `ratio` and `getImageDataHD` after first use;
- optimized `getImagePixels`;
- minor optimizations.