Fix for binary file writing in __capture_screenshot