Move MapBlock (de)serializing code out of Database class

**Backup your worlds before trying this**
This also fixes #1340