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.
Looks like it's assuming/hardcoding that the first section is always compressed (which is required for a few kernel processes but not in general.) I'd try removing and seeing if it breaks anything.