Adding writeCopy() to Realm

The method `writeCopy()` writes the entire Realm to a new write. During the write, the data is compacted, and the resulting file is smaller. The method is useful when an app migrates to a new version, and it wishes to reduce the file size to a minimum.

@bmunkholm @cmelchior @emanuelez 
Close the realm