Isn't an emacs buffer exactly that? Depending on what modes are turned on the way the file data is presented will also change.
For ex, how you can open a svg file, if you use the image mode you see the image representation otherwise you get the code.