Fixed save in wrong format after opening a file using a plugin

On Mac, opening a file using a plugin was not setting the mapDocument's
writerPluginFileName. This means that it would default to the TMX
format.

Replaced dynamic_cast with qobject_cast.

Closes #389