function encodeToBase64(editor, imgPath, pos) {
						var editorFile = editor.getFilePath();
						var defaultMimeType = 'application/octet-stream';

						if (editorFile === null) {
							throw "You should save your file before using this action";
						}

						// locate real image path
						file.locateFile(editorFile, imgPath, function (realImgPath) {
							if (realImgPath === null) {
								throw "Can't find " + imgPath + ' file';
							}

							file.read(realImgPath, function (err, content) {
								if (err) {
									throw 'Unable to read ' + realImgPath + ': ' + err;
								}

								var b64 = base64.encode(String(content));
								if (!b64) {
									throw "Can't encode file content to base64";
								}

								b64 = 'data:' + (actionUtils.mimeTypes[String(file.getExt(realImgPath))] || defaultMimeType) +
									';base64,' + b64;

								editor.replaceContent('$0' + b64, pos, pos + imgPath.length);
							});
						});

						return true;
					}
Encodes image to base64

@param {IEmmetEditor} editor
@param {String} imgPath Path to image
@param {Number} pos Caret position where image is located in the editor
@return {Boolean}