added encode option to create_file