tweaked BufferedPaintDC to work better on Windows and also on Mac OS X