Use mime types and move open_file to text api

Change setPlainText to require a mime_type parameter and an encoding