Pass sys.stdout directly to the reducer

There is no need to reopen the file.
Print exception when reducer fails
Combine runmapper and runreducer into runner
Use a single file for defining the job

Since the mapper and reducer are tightly coupled, they are easier to
write then they are in the same file -- changing something in the
mapper often requires a corresponding change in the reducer.
Use more telling name for tmp container