Improve the loader a bit

Clean up the loader to open the file only once and pass the IOFile around to functions requiring it, and add a real file detection function based on its magic.
It's (base + offset * sizeof(u8)) vs (base + offset * sizeof(char)) isn't it?
For the platforms that we support, I think they are the same size