Julia 0.4 compatibility fixes

This will still break on 0.4, because `invoke` is broken (see JuliaLang/julia#8861 and JuliaLang/julia#8862), but it fixes #717.