Fix for writing screenshot file

Hi, 
I added the fix to for taking a screenshot to the develop branch.
I also went ahead and added a test for the capture_screenshot method - I create a file, check it exists and is a png file using [imghdr](http://docs.python.org/2/library/imghdr.html), and finally delete it. 

If you don't want the test for some reason, I can send a pull request for the screenshot fix only (after all, it's a single character fix :) )