Fix #356 (Get rid of cached_open)

- Removed cached_open and APPEND_FD_CACHE stuff.
- Changed some file access code to 'with' statement style

Performance on my machine (both with warm disk caches):
- before: /mp --rescan=all  408.37s user 104.86s system 99% cpu 8:36.13 total
- after: ./mp --rescan=all  451.99s user 170.44s system 98% cpu 10:30.30 total

(Hopefully) should also fix #432 and #496.