Confusion on using FFTW 3.3.4 (C version) for real and even data sets
If the imaginary part is very small you are probably not doing anything wrong.  This is a common occurrence due to floating point quantization noise.  As long as you know the result should be real and the imaginary part is small, just drop the imaginary part.