One solution would be to load the file contents into memory and serve the content with the appropriate header. This of course depends on the size of the file, you don't want to load large files into memory and serve it like this. You could copy the file into a temporary web accessable area and provide a link to it.
Other things to consider, do you want to remove the converted file after you've sered it, so that you don't end up filling some filesystem with old files people have downloaded? Perhaps you'd need to write a housekeeping script to tidy up these files/areas on a regular basis. Clarify your requirements and consider the implications of your system. See also Print to Browser Headers Not Working Serve a file from a CGI script.