added output parameter to mappers/reducers

to aid in testing, mapper and reducer functions now have an optional
output parameter. The default is sys.stdout, so they all still work
unchanged with the map-reduce framework.