Added SVG and <img> formats, border option; optimized the code