Fixes for missing #includes and functions

This is a collection of fixes for build errors on windows (visual studio + mingw), mac and linux with certain compilers. For mingw this depends on an oiio fix:
https://github.com/OpenImageIO/oiio/pull/478