fix file writing: check_conflict call didn't close file handle

the check_conflict call has to do different things when it
checks a folder or file.

A typical python error came in checking:
    if not file_handle
for finding out that something is a directory
(opening it as a file failed), instead of checking:
    if file_handle is not None

Incidentally, a working file_handle evaluates False ...
remove unnecessary flask.g import from irodsstorage