         transform = CGAffineTransformConcat(transform, CGAffineTransformMakeTranslation(0.0, self.size.height))
         CGContextConcatCTM(context, transform)
 
-//        CGContextSetAllowsAntialiasing(context, true)
-//        CGContextSetShouldAntialias(context, true)
-
         let drawRect = CGRect(origin: CGPointZero, size: self.size)
 
         CGContextClipToMask(context, drawRect, maskImage.CGImage)

        return roundImage
    }

//    func bubbleImageWithTailDirection(tailDirection: MessageImageTailDirection, size: CGSize) -> UIImage {
//        let bubbleImage = self.fixRotation().cropToAspectRatio(size.width / size.height).resizeToTargetSize(size).bubbleImageWithTailDirection(tailDirection)
//
//        return bubbleImage
//    }
}

extension UIImage {

        return roundImage
    }

    struct BubbleMaskImage {

        static let leftTail: UIImage = {
            let scale = UIScreen.mainScreen().scale
            let orientation: UIImageOrientation = .Up
            var maskImage = UIImage(CGImage: UIImage(named: "left_tail_image_bubble")!.CGImage, scale: scale, orientation: orientation)!
            maskImage = maskImage.resizableImageWithCapInsets(UIEdgeInsets(top: 25, left: 27, bottom: 20, right: 20), resizingMode: UIImageResizingMode.Stretch)
            return maskImage
            }()

        static let rightTail: UIImage = {
            let scale = UIScreen.mainScreen().scale
            let orientation: UIImageOrientation = .UpMirrored
            var maskImage = UIImage(CGImage: UIImage(named: "left_tail_image_bubble")!.CGImage, scale: scale, orientation: orientation)!
            maskImage = maskImage.resizableImageWithCapInsets(UIEdgeInsets(top: 25, left: 27, bottom: 20, right: 20), resizingMode: UIImageResizingMode.Stretch)
            return maskImage
            }()
    }

    func bubbleImageWithTailDirection(tailDirection: MessageImageTailDirection, size: CGSize) -> UIImage {

        let orientation: UIImageOrientation = tailDirection == .Left ? .Up : .UpMirrored

        let maskImage: UIImage

        if tailDirection == .Left {
            maskImage = BubbleMaskImage.leftTail.renderAtSize(size)
        } else {
            maskImage = BubbleMaskImage.rightTail.renderAtSize(size)
        }

        let bubbleImage = self.fixRotation().cropToAspectRatio(size.width / size.height).resizeToTargetSize(size).maskWithImage(maskImage)

        return bubbleImage
    }

}
