Rotate image according to EXIF orientation not working from a plugin
The best way to do this would be to follow the same flow that Craft does - clean the filename, move to a temporary location, operate from there and afterwards delete the temporary file.

Craft has an example in it's codebase to help you out. Just remember to delete the temp file afterwards.