Output error messages to stderr

Update the output of error messages so that the messages go
to stderr instead of stdout.

We can't use the print() method because its availability and
usage varies between Python versions 2.4 and 3.x; instead we
add a wrapper method that directly writes the error message
to sys.stderr, adds a newline, and flushes stderr.

Also reorder the imports into alphabetical order.

Fixes #26

Change-Id: Ib3eae2b70254787fd06d2f9997bc98feb65958d8