Since you mentioned JPEG, are you displaying the image just
after the upload? In that case, it's the HTTP server (Apache, IIS,
etc.) that's probably locking your file for a while. I don't know
if there's really a way to overcome this.
What I would do (in a Content management system, for
example), would be a specific file-task queue, which stores a
record in the database if the file deletion didn't work (use
try-catch), and then run a specific page once in a while
(cfschedule) which tries to delete the files that are waiting for
their doom.