Use 3-arg type() to construct PlotObjectEncoder
Remove duplicated code from NotebookSessionMixin.dumps()
Move duplicated code to convert_models() in bokeh/session.py
Don't modify session state in get_ref()