Will be used when we implement image reload support soon.
In the process, RAII-ify everything in load_image(), so that
we can return nullptr at any given place without being worried
about resource leaks.
In the process, get rid of some deprecated FFmpeg API use.