You may have a look at the following packages available in R.
The R package forecast uses loess decomposition of time series to identify and replace outliers.
The R package tsoutliers implements the Chen and Liu procedure for detection of outliers in time series. A description of the procedure and the implementation is given in the documentation attached to the package. You may also see this post.