Instead of the low-level C API the C++ filesystem library and C++ iostreams shall be used for image file operations (protobuf interface) and other file-based operations. This will result in more portable and more transparent code with better error handling.