Pass nbformat object to write call to save .py script

Closes gh-4495
Add test for saving notebook with .py script
Merge pull request #4496 from takluyver/i4495

Pass nbformat object to write call to save .py script

Closes #4495