Modified download.php. Made to write the file to correct extension.