class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
I am not too sure what can be the cause. The line 3036 is part of the code which checks that the destination directory is writable. It attemps to create a temp file (which it seems to have done with success, and then deletes it on line 3036).
Can you replace this line with the following?
So we should have more information.
And are you sure it fails only when you use file_max_size code?