utils: simplify flopen() usage

Make flopen context manager that automatically unlocks file on __exit__
(if fcntl is supported by the platform)