stop passing so many parameters around

The write_out* methods all use to take multiple parameters which were
actually available without having to pass them around. Made these
parameters ivars and attr_reader'ed all of them.