How to save image in file in sub-folder

I think I created a sub-folder and a file in it , but how do I save and display an image from the web ? I created a gradient background that fades to different colors and I want to save the background to the file and display it as the background on my app . Can someone help me ? This is what I have now :

main.lua :

local lfs = require "lfs" -- get raw path to app's Documents directory local docs\_path = system.pathForFile( "", system.DocumentsDirectory ) -- change current working directory local success = lfs.chdir( docs\_path ) -- returns true on success local new\_folder\_path local dname = "Background" if success then lfs.mkdir( dname ) new\_folder\_path = lfs.currentdir() .. "/" .. dname end -- Data (string) to write local saveData = html -- Path for the file to write local path = system.pathForFile( "Background.txt", system.DocumentsDirectory ) -- Open the file handle local file, errorString = io.open( path, "w" ) if not file then -- Error occurred; output the cause print( "File error: " .. errorString ) else -- Write data to file file:write( saveData ) -- Close the file handle io.close( file ) end file = nil local path = system.pathForFile( "Background/Background.txt", system.DocumentsDirectory ) local fileHandle = io.open( path ) -- You can now use fileHandle:read or fileHandle:write to read or write the file.