String mimeType = MimeUtils.getMimeType(templateFileName);
logger.debug("Mime type is = " + mimeType);
response.setContentType(mimeType);
BASE64Decoder bASE64Decoder = new BASE64Decoder();
byte[] templateContent = bASE64Decoder.decodeBuffer(template.getContent());
response.setContentLength(templateContent.length);
response.getOutputStream().write(templateContent);
response.getOutputStream().flush();
response.getOutputStream().close();