Reformatted to better comply with PEP 8. Added check to make sure render engine matches filename. Some other misc minor fixes.