committing a cross-platformified version that has flushing and correct image load and invalid RTH handling