Rather than using a custom field element for handling file uploading, rewrite the module to use the core File module's APIs. It may help to review the Examples module's file example code.