Utility function for handling emscripten modules and transfering arrays to and from module memory.