Add missing include
Whitespace cleanup
Text all exports as sending file

It makes no sense to go through htmlspecialchars for binary formats.
Correctly set expectation on output
Missing include and variable