Two things - the code is unreadable because it's not formatted. Please use the CODE tags (see my sig). Also, from what I can make out of the code, it just copies one file into another, which isn't what you described.

Regarding your question, if you don't know the file format, how can you expect to convert it into anything familiar?

First, solve the problem. Then, write the code...
John Johnson