Fix writing screenshot file