An apparatus for encoding an image, the apparatus comprising: an intra prediction unit configured to generate a prediction block corresponding to a current block according to an intra prediction mode selected out of a plurality of intra prediction modes; a transform unit configured to transform a residual block obtained by calculating a difference between an original block of the current block and the prediction block to generate a transform block; a quantization unit configured to quantize the transform block to generate a quantized transform block using a quantization step size; a scanning unit configured to scan quantized transform coefficients of the quantized transform block to generate one-dimensional quantized transform coefficients; and an entropy coding unit configured to entropy-code the 1D quantized transform coefficients, wherein, when a size of the transform block is larger than 4x4, the scanning unit divides the quantized transform coefficients into a plurality of sub-blocks and scans the plurality of sub-blocks and the quantized transform coefficients of each sub-block using a scan pattern determined according to the selected intra prediction mode, wherein, when the selected intra prediction mode is a horizontal mode, the scan pattern is a vertical scan, wherein information indicating a position of the last non-zero coefficient of the quantized transform block is transmitted to a decoder, and wherein the intra prediction unit includes: a reference pixel generating unit configured to generate reference pixels using available reference pixels of the current block when unavailable reference pixels exist; a reference pixel filtering unit configured to adaptively filter reference pixels adjacent to the current block based on the selected intra prediction mode and a size of the current block; a prediction block generating unit configured to generate a prediction block of the current block according to the selected intra prediction mode; and a prediction block filtering unit configured to adaptively filter some prediction pixels of the prediction block based on the selected intra prediction mode and the size of the current block. an intra prediction unit configured to generate a prediction block corresponding to a current block according to an intra prediction mode selected out of a plurality of intra prediction modes; a transform unit configured to transform a residual block obtained by calculating a difference between an original block of the current block and the prediction block to generate a transform block; a quantization unit configured to quantize the transform block to generate a quantized transform block using a quantization step size; a scanning unit configured to scan quantized transform coefficients of the quantized transform block to generate one-dimensional quantized transform coefficients; and an entropy coding unit configured to entropy-code the 1D quantized transform coefficients, wherein, when a size of the transform block is larger than 4x4, the scanning unit divides the quantized transform coefficients into a plurality of sub-blocks and scans the plurality of sub-blocks and the quantized transform coefficients of each sub-block using a scan pattern determined according to the selected intra prediction mode, wherein, when the selected intra prediction mode is a horizontal mode, the scan pattern is a vertical scan, wherein information indicating a position of the last non-zero coefficient of the quantized transform block is transmitted to a decoder, and wherein the intra prediction unit includes: a reference pixel generating unit configured to generate reference pixels using available reference pixels of the current block when unavailable reference pixels exist; a reference pixel filtering unit configured to adaptively filter reference pixels adjacent to the current block based on the selected intra prediction mode and a size of the current block; a prediction block generating unit configured to generate a prediction block of the current block according to the selected intra prediction mode; and a prediction block filtering unit configured to adaptively filter some prediction pixels of the prediction block based on the selected intra prediction mode and the size of the current block. a reference pixel generating unit configured to generate reference pixels using available reference pixels of the current block when unavailable reference pixels exist; a reference pixel filtering unit configured to adaptively filter reference pixels adjacent to the current block based on the selected intra prediction mode and a size of the current block; a prediction block generating unit configured to generate a prediction block of the current block according to the selected intra prediction mode; and a prediction block filtering unit configured to adaptively filter some prediction pixels of the prediction block based on the selected intra prediction mode and the size of the current block.