An apparatus for encoding an image, the apparatus comprising: a coding mode determiner configured to divide an input image into a plurality of coding units; an intra predictor configured to generate a prediction block using intra prediction; a transform/quantization unit configured to transform and quantize a residual block to generate a quantized transform block; an inverse quantization/transform unit configured to inversely quantize and inversely transform the quantized transform block; and an entropy coder configured to entropy-code quantized transform coefficients of the quantized transform block, wherein the quantized transform coefficients are divided into a plurality of sub-blocks if it is determined that a size of a transform block is equal to or larger than 8x8 in an intra prediction, wherein the plurality of sub-blocks are scanned and non-zero coefficients of each sub-block are scanned according to a scan pattern, wherein said scan pattern for scanning the plurality of sub-blocks and for scanning the non-zero coefficients of each sub-block is determined by an intra prediction mode of the prediction block to entropy-code the scanned non-zero coefficients, wherein, when the intra prediction mode is a horizontal mode, the scan pattern is a vertical scan pattern, wherein the intra prediction mode is coded based on an upper intra prediction mode of an upper block of a current block and a left intra prediction mode of a left block of the current block, and when the upper block or the left block is not encoded in intra prediction mode, the upper intra prediction mode or the left intra prediction mode is set to a DC mode. a coding mode determiner configured to divide an input image into a plurality of coding units; an intra predictor configured to generate a prediction block using intra prediction; a transform/quantization unit configured to transform and quantize a residual block to generate a quantized transform block; an inverse quantization/transform unit configured to inversely quantize and inversely transform the quantized transform block; and an entropy coder configured to entropy-code quantized transform coefficients of the quantized transform block, wherein the quantized transform coefficients are divided into a plurality of sub-blocks if it is determined that a size of a transform block is equal to or larger than 8x8 in an intra prediction, wherein the plurality of sub-blocks are scanned and non-zero coefficients of each sub-block are scanned according to a scan pattern, wherein said scan pattern for scanning the plurality of sub-blocks and for scanning the non-zero coefficients of each sub-block is determined by an intra prediction mode of the prediction block to entropy-code the scanned non-zero coefficients, wherein, when the intra prediction mode is a horizontal mode, the scan pattern is a vertical scan pattern, wherein the intra prediction mode is coded based on an upper intra prediction mode of an upper block of a current block and a left intra prediction mode of a left block of the current block, and when the upper block or the left block is not encoded in intra prediction mode, the upper intra prediction mode or the left intra prediction mode is set to a DC mode.