nbconvert: Backport fixes

Fixes cherry-picked from #3914 and #3923