def tofile(self, path_to_file, replace_file=False):
        """ 
        save blob content from StorageBlobModel instance to file in given path/file. Parameters are:
        - path_to_file (required): local path or file
        """

        # create full path
        if os.path.isdir(path_to_file):
            if self.filename != '':
                path_to_file = os.path.join(path_to_file, self.filename)
            
            else:
                # guess extention from mimetype
                path_to_file = os.path.join(path_to_file, self.name + guess_extension(self.properties.content_settings.content_type))

        elif os.path.isfile(path_to_file):
            # check if given file extention fits to self.filename or mime type
            #  
            if self.filename != '':
                if os.path.splitext(self.filename)[1] != os.path.splitext(path_to_file)[1]:
                    raise AzureStorageWrapException(self, 'can not save blob to file because file extention {!s} does not fit to source file or mime type'.format(path_to_file))
      
            else:
                mimetype = guess_type(path_to_file)[0]
                if mimtype != self.properties.content_settings.content_type:
                    raise AzureStorageWrapException(self, 'can not save blob to file because file extention {!s} does not fit to source file or mime type'.format(path_to_file))
                
        else:
            raise AzureStorageWrapException(self, 'can not save blob to file because {!s} is not a dir nor a file'.format(path_to_file))
        
        # check if file exists (and replace or error)
        if os.path.isfile(path_to_file):
            if replace_file:
                os.remove(path_to_file)
            else:
                raise AzureStorageWrapException(self, 'can not save blob to file {!s} because file exists and replace_file is False'.format(path_to_file))

        # save file into self.__content__
        self.filename = os.path.basename(path_to_file)
        with open(path_to_file, "wb") as out_file:
            out_file.write(self.content)

        return path_to_file