added writeAlpha