render.py: Break out some more code

Benjamin Mako Hill || Want to submit a patch?