Clean up the file code and add native port of RAW decoding