more robust screenshot creation